package com.itheima.dao;

import com.itheima.domain.Student;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author 王加鑫
 * @Date 2021/7/23 21:30
 * @Since JDK 1.9
 */
@Repository
public interface StudentDao {

    @Select("insert into student values(null,#{name},#{age},#{birthday})")
    public void save(Student student);

    @Update("update student set name = #{name},age = #{age},birthday = #{birthday} where id = #{id}")
    public void update(Student student);

    @Delete("delete from student where sid = #{id}")
    public void delete(Integer id);

    @Select("select * from student where sid = #{id}")
    public Student findById(Integer id);

    @Select("select * from student")
    public List<Student> findAll();

    @Select("select * from student where name = #{name}")
    public Student findByName(String name);
}
